//
//  StockTimeAnalysisViewController.m
//  EMMApp
//
//  Created by Mac on 16/7/10.
//  Copyright © 2016年 YiXun. All rights reserved.
//

#import "StockTimeAnalysisViewController.h"
#import "MenuLitsView.h"
#import "EMMAnalysisCell.h"
#import "ZFChart.h"
#import "GetStockTimeListApi.h"


@interface StockTimeAnalysisViewController ()<UITableViewDelegate,UITableViewDataSource> {
    NSString *num;
    NSString *titleOne;
    NSString *numOne;
    NSString *titleTwo;
    NSString *followString;
    NSString *followStringOne;
    NSInteger touchIndex;
    BOOL _isOne;
    BOOL _istwo;
    NSString *timer;
    NSInteger cHigth;
    NSString *titleThree;
    NSInteger h;
    NSNumber *max;
    int number;
}

@property (nonatomic, strong) UITableView *tableView;

@property (strong, nonatomic) UIView *headBackView;

@property (strong, nonatomic) UIImageView *headImageview;
@property (strong, nonatomic)UIButton *djBtn;
@property (strong, nonatomic)UIButton *btn;
@property (nonatomic, strong) UIScrollView *mainScrollView;

@property (nonatomic, strong) MenuLitsView *menuOne;
@property (nonatomic, strong) MenuLitsView *menuTwo;

@property (strong, nonatomic) UIView *timerView;
@property (strong, nonatomic) UIButton *timerBtn;

@property (strong, nonatomic) ZFPieChart * pieChart;
@property (strong, nonatomic) ZFLineChart * lineChart;

@property (nonatomic, strong) UILabel *jlLabel;

@property (nonatomic, strong) NSMutableArray *dataArr;
@property (nonatomic, strong) NSMutableArray *dataNameArr;
@property (nonatomic, strong) NSMutableArray *dataNumArr;


@end

@implementation StockTimeAnalysisViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _dataArr = [[NSMutableArray alloc] init];
    _dataNumArr = [[NSMutableArray alloc] init];
    _dataNameArr = [[NSMutableArray alloc] init];
    
    num = @"0";
    numOne = @"0";
    followString = @"1";
    followStringOne = @"1";
    titleOne = @"1个月";
    titleTwo = @"公寓";
    cHigth = 400;
    [self postGetStockTimeListApiMonthlyLimit:followString propertyType:followStringOne];
    
    [self creatDropDownView];
    [self creatNavigationController];
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 45, EMM_WIDTH, EMM_HEIGHT-SafeAreaTopHeight-45) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_tableView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

#pragma mark - 导航

- (void)creatNavigationController {
    [self updateNavBar];
    self.navigationItem.title = @"存量时间分析";
    
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setFrame:CGRectMake(0, 0, 54 ,44)];
    [backBtn addTarget:self
                action:@selector(backToPreviousPage:)
      forControlEvents:UIControlEventTouchUpInside];
    [backBtn setBackgroundColor:[UIColor clearColor]];
    [backBtn setImage:[UIImage imageNamed:@"ico_back"] forState:UIControlStateNormal];
    backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    if (EMM_WIDTH <= 320) {
        backBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
    }else if (EMM_WIDTH > 375){
        backBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
    }else{
        backBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
    }    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];

}

- (void)backToPreviousPage:(UIButton *)btn {
    [self removeSubViewOne];
    [self removeSubViewTWo];
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
   
}

- (void)postGetStockTimeListApiMonthlyLimit:(NSString *)monthlyLimit propertyType:(NSString *)propertyType  {
    [self showHudInWindow:@"正在加载请稍等..."];

    [_dataArr removeAllObjects];
    [_dataNumArr removeAllObjects];
    [_dataNameArr removeAllObjects];
    
    GetStockTimeListApi *api = [[GetStockTimeListApi alloc] initWithMonthlyLimit:monthlyLimit propertyType:propertyType];
    [api startWithCompletionBlockWithSuccess:^(YTKBaseRequest *request) {
        GetStockTimeListApi *result = (GetStockTimeListApi *)request;
        if (result.isSuccess) {
            GetStockTimeList *get = result.resultData;
            if (get.stockTimeList.count > 0) {
                cHigth = 300 + get.stockTimeList.count *25;
            }else {
                cHigth = 400;
            }
            for (StockTimeList *list in get.stockTimeList) {
                [_dataArr addObject:list];
                [_dataNameArr addObject:list.stockTimeName];
                [_dataNumArr addObject:list.stockTimeNum];
            }
            NSInteger x = 0;
            for (int i = 0; i < _dataNumArr.count; i++) {
                NSInteger xNm = [[_dataNumArr objectAtIndex:i] integerValue];
                x = x + xNm;
            }
            if (x > 0) {
                [self showPieChartvalue];
            }
           
        } else {
           
            [self showToast:result.resultData.errorMsg];
            /*
             提示语：账号权限发生变动，请重新登录
             code随机18位唯一码：108E65843mYuwqb01X
             //YUplf0wyU5vPVssLSG 对应的异地登录退出登录
             */
            if ([result.resultData.errorCode isEqualToString:@"YUplf0wyU5vPVssLSG"] || [result.resultData.errorCode isEqualToString:@"108E65843mYuwqb01X"]) {
                NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
                NSDictionary *dictionary = [defs dictionaryRepresentation];
                for(NSString *key in [dictionary allKeys]){
                    if ([key isEqualToString:@"DeviceToken123"] ||
                        [key isEqualToString:@"loginText"] ||
                        [key isEqualToString:@"provinceCityDistrict"]) {
                    }else {
                        [defs removeObjectForKey:key];
                        [defs synchronize];
                    }
                }
                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:result.resultData.errorMsg preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                    [appInstance showLogin];
                }];
                [alertController addAction:cancelAction];
                [self presentViewController:alertController animated:YES completion:nil];
            }
        }
        [_tableView reloadData];
        [self hideHud];
    } failure:^(YTKBaseRequest *request) {
        [self showToast:@"连接服务器失败，请检查网络！"];
        [self hideHud];
    }];
}




#pragma mark - scrollViewDidScroll --> 滑动响应事件
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (_mainScrollView.scrollEnabled) {
        [self headLineViewScrollWithIndex:scrollView.contentOffset.x/EMM_WIDTH];
    }
}

#pragma mark - UITableView代理
//返回几个表头
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

//每一个表头下返回几行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 1;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
   
    return EMM_HEIGHT-SafeAreaTopHeight-45;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"EMMAnalysisCellId";
    EMMAnalysisCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"EMMAnalysisCell" owner:self options:nil] lastObject];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor whiteColor];
    if (indexPath.row == 0) {
//        [cell addSubview:self.headBackView];
        if (_dataArr.count > 0) {
            NSInteger x = 0;
            for (int i = 0; i < _dataNumArr.count; i++) {
               NSInteger xNm = [[_dataNumArr objectAtIndex:i] integerValue];
                x = x + xNm;
            }
            if (x > 0) {
                [cell addSubview:_pieChart];
            }else {
                UILabel *jlLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 300/2, EMM_WIDTH, 20)];
                jlLabel.text = @"当前没有记录";
                jlLabel.textAlignment = NSTextAlignmentCenter;
                jlLabel.font = [UIFont systemFontOfSize:15];
                [cell addSubview:jlLabel];
            }
        }else {
            UILabel *jlLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 300/2, EMM_WIDTH, 20)];
            jlLabel.text = @"当前没有记录";
            jlLabel.textAlignment = NSTextAlignmentCenter;
            jlLabel.font = [UIFont systemFontOfSize:15];
            [cell addSubview:jlLabel];
        }
    }
    return cell;
}



#pragma mark - 跳出层初始化
- (void)creatDropDownView {//
    self.headBackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, EMM_WIDTH, 45)];
    self.headBackView.backgroundColor = [UIColor colorFromHexCode:@"#fff5e9"];
    [self.view addSubview:self.headBackView];
    
    UILabel *l1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 44.5, EMM_WIDTH, 0.5)];
    l1.backgroundColor = [UIColor colorFromHexCode:@"#CCCCCC"];
    [self.headBackView addSubview:l1];
    
    _djBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _djBtn.frame = CGRectMake(0, 5, EMM_WIDTH/2, 32);
    _djBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [_djBtn setTitle:titleOne forState:UIControlStateNormal];
    [_djBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [_djBtn setImage:[UIImage imageNamed:@"sj_down"] forState:UIControlStateNormal];    //设置button背景显示图片
    _djBtn.tag = 2001;
//    [_djBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _djBtn.titleLabel.bounds.size.width+EMM_WIDTH/2-50, 0, _djBtn.titleLabel.bounds.size.width)];
    [_djBtn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:5];
    NSLog(@"%f",_djBtn.titleLabel.bounds.size.width);
    [_djBtn addTarget:self action:@selector(headButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.headBackView addSubview:_djBtn];
    
    _btn = [UIButton buttonWithType:UIButtonTypeCustom];
    _btn.frame = CGRectMake(EMM_WIDTH/2, 5, EMM_WIDTH/2, 32);
    _btn.titleLabel.font = [UIFont systemFontOfSize:16];
    [_btn setTitle:titleTwo forState:UIControlStateNormal];
    [_btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    _btn.tag = 2002;
    [_btn setImage:[UIImage imageNamed:@"sj_down"] forState:UIControlStateNormal];    //设置button背景显示图片
//    [_btn setImageEdgeInsets:UIEdgeInsetsMake(0, _btn.titleLabel.bounds.size.width+EMM_WIDTH/2-60, 0, _btn.titleLabel.bounds.size.width)];
    [_btn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:5];
    [_btn addTarget:self action:@selector(headButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.headBackView addSubview:_btn];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(EMM_WIDTH/2, 7.5, 1, 30)];
    label.backgroundColor = [UIColor colorFromHexCode:@"#ff7200"];
    [self.headBackView addSubview:label];
    
    NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15],};
    CGSize textSize = [titleOne boundingRectWithSize:CGSizeMake(100, 100) options:NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil].size;
    _headImageview = [[UIImageView alloc] initWithFrame:CGRectMake((EMM_WIDTH/2-textSize.width)/2-10, 43, textSize.width, 2)];
    _headImageview.backgroundColor = [UIColor grayColor];
    [self.headBackView addSubview:self.headImageview];
    
    _isOne = YES;
    _istwo = YES;
    
    _jlLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, (cHigth-20)/2, EMM_WIDTH, 20)];
    _jlLabel.text = @"当前没有记录";
    _jlLabel.textAlignment = NSTextAlignmentCenter;
    _jlLabel.font = [UIFont systemFontOfSize:15];
    _jlLabel.textColor = [UIColor colorFromHexCode:@"#1A1A1A"];
    _jlLabel.hidden = YES;
}

- (void)showPieChartvalue {
    NSMutableArray *arr3 = [NSMutableArray arrayWithObjects:
                            ZFColor(255, 231, 110, 1),ZFColor(255, 197, 153, 1),
                            ZFColor(255, 180, 103, 1),ZFColor(255, 144, 72, 1),
                            ZFColor(245, 74, 43, 1), ZFColor(251, 115, 136, 1),
                            ZFColor(245, 60, 127, 1),ZFColor(243, 53, 94, 1),
                            ZFColor(204, 31, 26, 1),ZFColor(117, 12, 12, 1),
                            ZFColor(197, 244, 255, 1),ZFColor(103, 194, 213, 1),
                            ZFColor(81, 153, 170, 1),ZFColor(4, 151, 150, 1),
                            ZFColor(8, 150, 104, 1),ZFColor(140, 211, 231, 1),
                            ZFColor(33, 185, 211, 1),ZFColor(0, 110, 168, 1),
                            ZFColor(0, 90, 166, 1),ZFColor(91, 84, 119, 1),nil];
    
    _pieChart = [[ZFPieChart alloc] initWithFrame:CGRectMake(0, 0, EMM_WIDTH, EMM_HEIGHT-SafeAreaTopHeight-45) isInitWith:1];
    
    _pieChart.valueArray = _dataNumArr;
    _pieChart.nameArray = _dataNameArr;
    _pieChart.colorArray = arr3;
    _pieChart.percentType = kPercentTypeInteger;
    _pieChart.scrollEnabled = NO;
    [_pieChart strokePath:3];
}


- (void)setScrollView:(UIScrollView *)scrollView width:(CGFloat)width {
    
    scrollView.showsHorizontalScrollIndicator = NO;
    
    scrollView.showsVerticalScrollIndicator = NO;
    
    scrollView.pagingEnabled = YES;
    
    scrollView.bounces = NO;
    
    scrollView.contentSize = CGSizeMake(width,scrollView.bounds.size.height);
    
}


#pragma mark - 顶部按键响应事件
- (void)headButtonClick:(UIButton *)button {
    [self headLineViewScrollWithIndex:button.tag-2001];
    [UIView animateWithDuration:0.5 animations:^{
        _mainScrollView.contentOffset = CGPointMake((button.tag-2001)*ScreenSize.width, 0);
    }];
    
    if (button.tag == 2001) {
        
        
        if (_isOne == YES ) {
            [self menulistShowUIOne];
            [_djBtn setImage:[UIImage imageNamed:@"sj_up"] forState:UIControlStateNormal];
            _isOne = NO;
            [_btn setImage:[UIImage imageNamed:@"sj_down"] forState:UIControlStateNormal];    //设置button背景显示图片
            [_djBtn setTitleColor:[UIColor colorFromHexCode:@"#e97300"] forState:UIControlStateNormal];
            [_btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
            //设置button背景显示图片
            _headImageview.backgroundColor = [UIColor colorFromHexCode:@"#e97300"];
            
        }else {
            [self removeSubViewOne];
            [_djBtn setImage:[UIImage imageNamed:@"sj_down"] forState:UIControlStateNormal];
            _isOne = YES;
            [_djBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
            _headImageview.backgroundColor = [UIColor grayColor];
        }
        _istwo = YES;
        [self removeSubViewTWo];
        
    }else if (button.tag == 2002) {
        
        if (_istwo == YES ) {
            [self menulistShowUITwo];
            [_btn setImage:[UIImage imageNamed:@"sj_up"] forState:UIControlStateNormal];
            _istwo = NO;
            [_djBtn setImage:[UIImage imageNamed:@"sj_down"] forState:UIControlStateNormal];    //设置button背景显示图片
            
            [_btn setTitleColor:[UIColor colorFromHexCode:@"#e97300"] forState:UIControlStateNormal];
            [_djBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
            _headImageview.backgroundColor = [UIColor colorFromHexCode:@"#e97300"];
            
        }else {
            [self removeSubViewTWo];
            [_btn setImage:[UIImage imageNamed:@"sj_down"] forState:UIControlStateNormal];
            _istwo = YES;
            [_btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
            _headImageview.backgroundColor = [UIColor grayColor];
        }
        _isOne = YES;
        [self removeSubViewOne];
    }
    [_btn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:5];
    [_djBtn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:5];

}


////改变箭头方向和字体颜色
//- (void)changeTitleColorAndWay1
//{
//    [_djBtn setTitleColor:[UIColor colorFromHexCode:@"#ff7200"] forState:UIControlStateNormal];
//    [_btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//    [_djBtn setImage:[UIImage imageNamed:@"sj_up"] forState:UIControlStateNormal];
//    [_btn setImage:[UIImage imageNamed:@"sj_down"] forState:UIControlStateNormal];
//    
//    
//}
//
//- (void)changeTitleColorAndWay2{
//    [_djBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//    [_btn setTitleColor:[UIColor colorFromHexCode:@"#ff7200"] forState:UIControlStateNormal];
//    [_djBtn setImage:[UIImage imageNamed:@"sj_down"] forState:UIControlStateNormal];
//    [_btn setImage:[UIImage imageNamed:@"sj_up"] forState:UIControlStateNormal];
//}


#pragma mark - 第一个
- (void)menulistShowUIOne {
    //1、意向等级（默认）；2、意向户型；3、需求面积；4、预算总价；5、客户年龄；6、客户状态
    NSArray *arr = [NSArray arrayWithObjects:
                    @"1个月(默认)",@"2个月",@"3个月",@"4个月",@"5个月",@"6个月",
                    @"7个月",@"8个月",@"9个月",@"10个月",@"11个月",@"12个月",
                    @"13个月",@"14个月",@"15个月",@"16个月",@"17个月",@"18个月",
                    @"19个月",@"20个月",@"21个月",@"22个月",@"23个月",@"24个月",nil];
    _menuOne = [[MenuLitsView alloc] initWithFrame:CGRectMake(0, SafeAreaTopHeight+45, EMM_WIDTH, EMM_HEIGHT-SafeAreaTopHeight-45) items:arr indet:num isShowUI:NO guodu:6*50];
    _menuOne.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    [[UIApplication sharedApplication].keyWindow addSubview:_menuOne];
    __block MenuLitsView *weakSelf = _menuOne;
    __block StockTimeAnalysisViewController *blockSelf = self;
    [weakSelf setMenuLitsBlock:^(NSString *title, NSString *indet) {
        [_djBtn setImage:[UIImage imageNamed:@"sj_down"] forState:UIControlStateNormal];
        if ([NSString isStringEmpty2:indet] == NO) {
            num = indet;
            followString = [NSString stringWithFormat:@"%ld",[indet integerValue]+1];
            cHigth = 400;
            if ([indet isEqualToString:@"0"]) {
                titleOne = @"1个月";
                [_djBtn setTitle:@"1个月" forState:UIControlStateNormal];
            }else {
                titleOne = title;

                [_djBtn setTitle:title forState:UIControlStateNormal];
            }
            NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15],};
            CGSize textSize = [_djBtn.titleLabel.text boundingRectWithSize:CGSizeMake(100, 100) options:NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil].size;
            self.headImageview.frame = CGRectMake((EMM_WIDTH/2-textSize.width)/2-10, 43, textSize.width, 2);
            [_tableView reloadData];
            [blockSelf postGetStockTimeListApiMonthlyLimit:followString propertyType:followStringOne];
            [_tableView reloadData];
        }else {
            if ([NSString isStringEmpty2:titleOne] == NO) {
                [_djBtn setTitle:titleOne forState:UIControlStateNormal];
            }else {
                [_djBtn setTitle:@"1个月" forState:UIControlStateNormal];
            }
            
        }
        [_djBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        [_djBtn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:5];
        _headImageview.backgroundColor = [UIColor colorFromHexCode:@"#5A5A5A"];
        _isOne = YES;
        [weakSelf removeFromSuperview];
    }];
}

#pragma mark - 第二个图时间
- (void)menulistShowUITwo {
     NSArray *arr = [NSArray arrayWithObjects:@"公寓",@"别墅",@"车位", nil];
    _menuTwo = [[MenuLitsView alloc] initWithFrame:CGRectMake(0, SafeAreaTopHeight+45, EMM_WIDTH, EMM_HEIGHT-SafeAreaTopHeight-45) items:arr indet:numOne isShowUI:NO guodu:arr.count*50];
    _menuTwo.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    [[UIApplication sharedApplication].keyWindow addSubview:_menuTwo];
    __block MenuLitsView *weakSelf = _menuTwo;
    __block StockTimeAnalysisViewController *blockSelf = self;
    [weakSelf setMenuLitsBlock:^(NSString *title, NSString *indet) {
        [_btn setImage:[UIImage imageNamed:@"sj_down"] forState:UIControlStateNormal];
        if ([NSString isStringEmpty2:indet] == NO) {
            numOne = indet;
            titleTwo = title;
            followStringOne = [NSString stringWithFormat:@"%ld",[indet integerValue]+1];
            [blockSelf postGetStockTimeListApiMonthlyLimit:followString propertyType:followStringOne];
            [_btn setTitle:title forState:UIControlStateNormal];
            
        }else {
            if ([NSString isStringEmpty2:titleOne] == NO) {
                [_btn setTitle:titleTwo forState:UIControlStateNormal];
            }else {
                [_btn setTitle:@"公寓" forState:UIControlStateNormal];
            }
            
        }
        [_btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        _headImageview.backgroundColor = [UIColor colorFromHexCode:@"#5A5A5A"];
        [_btn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:5];
        _istwo = YES;
        [weakSelf removeFromSuperview];
    }];
}

- (void)removeSubViewOne {
    [_menuOne removeFromSuperview];
    _menuOne = nil;
}
- (void)removeSubViewTWo {
    [_menuTwo removeFromSuperview];
    _menuTwo = nil;
}
#pragma mark - 顶部线移动,
- (void)headLineViewScrollWithIndex:(NSInteger)index {
    [UIView animateWithDuration:0.15 animations:^{
        if (index == 0) {
            NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15],};
            CGSize textSize = [_djBtn.titleLabel.text boundingRectWithSize:CGSizeMake(100, 100) options:NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil].size;
            self.headImageview.frame = CGRectMake((EMM_WIDTH/2-textSize.width)/2-10, 43, textSize.width, 2);
        }else if (index == 1) {
            NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15],};
            CGSize textSize = [_btn.titleLabel.text boundingRectWithSize:CGSizeMake(100, 100) options:NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil].size;
            self.headImageview.frame = CGRectMake((EMM_WIDTH/2-textSize.width)/2+EMM_WIDTH/2-10, 43, textSize.width, 2);
        }
    }];
}

@end
